/**
 * 
 */
package clids.ex2.filters;

import clids.ex2.common.exceptions.illiegalValuesException;

/**
 * @author Li0r
 * 
 */
public class BetweenFilter extends AbstractFilter {

	private AbstractFilter smallerThan;
	private AbstractFilter greaterThan;

	public BetweenFilter(String params) throws illiegalValuesException {
		super(params);
		double high = Double.parseDouble(parameters[1]);
		double low = Double.parseDouble(parameters[0]);
		if(low > high){
			throw new illiegalValuesException();
		}
		
		greaterThan = new GreaterThanFilter(low);
		smallerThan = new SmallerThanFilter(high);

	}

	@Override
	public boolean isValid(String file) {
		if ((smallerThan.isValid(file)) && (greaterThan.isValid(file))) {
			return true;
		}
		return false;
	}
}
